// 项目中所有的接口请求
import instance from './request.js'

// 1 首页请求 
export function getIndexData (params){
    return instance({
        url:'/index/index',
        method:'get',
        params:params
    })
}
// 2 专题请求
export function getTopicData (params){
    return instance({
        url:'/topic/list',
        method:'get',
        params:params
    })
}
// 3 分类请求
export function getCategoryData (params){
    return instance({
        url:'/catalog/index',
        method:'get',
        params:params
    })
}
export function getCurrentCategory (params){
    return instance({
        url:'/catalog/current',
        method:'get',
        params:params
    })
}
// 4 user页请求
export function loginFn (params){
    return instance({
        url:'/auth/loginByWeb',
        method:'post',
        data:params,
        headers: { 'content-type': 'application/json' }
    })
}
// 5 购物车接口
export function getCcarData (params){
    return instance({
        url:'/cart/index',
        method:'get',
        params:params,
        // 在拦截器中配置好了，这里可以不用写
        // headers:{'X-Nideshop-Token':'localStorage.getItem("token")'},
        
    })
}
// 6 搜索页接口
export function searchgoods (params){
    return instance({
        url:'/goods/list',
        method:'get',
        params:params
    })
}
// 7 详情页
export function getDetail (params){
    return instance({
        url:'/goods/detail',
        method:'get',
        params:params
    })
}
// 8 详情页加入购物车
export function addCarData (params){
    return instance({
        url:'/cart/add',
        method:'post',
        data:params,
    })
}
// 9 获取购物车总数量
export function getGoodsCount (params){
    return instance({
        url:'/cart/goodscount',
        method:'get',
        params:params
    })
}
// 10 删除请求
export function delCarData (params){
    return instance({
        url:'/cart/delete',
        method:'post',
        data:params,
    })
}
